# import cv2
# import dlib
import os
import sys
import random
import face_recognition
from PIL import Image, ImageDraw
import faceRecognise

# face_det = cv2.CascadeClassifier(
#     './config/haarcascade_frontalface_default.xml')
# encodingstrict = 0.53
# predicatestrict = 0.58
# load image data by image file path


# def getfaces(img, fn):
#     face = face_det.detectMultiScale(img, 1.3, 5)
#     if len(face):
#         for(x, y, w, h) in face:
#             img = cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)
#             img_face = img[y:y+h, x:x+w]
#             cv2.imwrite(fn, img_face)

# get encodings from image file


# predicate face encoding in target encodings


# get common face encodings in multi images, just renturn first most face encoding

faceRecognise.dumpFaceEncoding('./images/zw', './test/zw')
encodings = faceRecognise.loadFaceEncoding('./test/zw')

print(len(encodings))

print(faceRecognise.detectFace(
    faceRecognise.loadImg('./test/zw/0.jpeg'), encodings))
print(faceRecognise.detectFace(faceRecognise.loadImg('./test/zw/1.jpg'), encodings))
print(faceRecognise.detectFace(
    faceRecognise.loadImg('./test/zw/2.jpeg'), encodings))
print(faceRecognise.detectFace(
    faceRecognise.loadImg('./test/zw/3.jpeg'), encodings))
print(faceRecognise.detectFace(faceRecognise.loadImg('./test/zw/4.jpg'), encodings))
print(faceRecognise.detectFace(
    faceRecognise.loadImg('./test/zw/5.jpeg'), encodings))
print(faceRecognise.detectFace(faceRecognise.loadImg('./test/zw/6.jpg'), encodings))
print(faceRecognise.detectFace(faceRecognise.loadImg('./test/zw/7.jpg'), encodings))
